package com.ruoyi.common.controller;


import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.service.ICommonToolService;
import com.ruoyi.common.utils.ServletUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 通用模块Controller
 *
 * @author yiran
 * @date 2021-04-21
 */
@RestController
@RequestMapping("/common/tool")
class CommonToolController extends BaseController{

    @Autowired
    private ICommonToolService commonService;

    @GetMapping("/createUserDict")
    public Map createUserDict(){
        String keyWord = ServletUtils.getParameter("keyWord");
        Map parameterMap = ServletUtils.getParameterMap();
        Map<String,String> retData = new HashMap<>();
        List<Map> comboxData = commonService.createUserCombox(null);
        for (Map<String,String> map:comboxData) {
            retData.put(map.get("key"),map.get("value"));
        }
        return retData;
    }

    @GetMapping("/createDeptDict")
    public Map createDeptDict(){
        Map<String,String> retData = new HashMap<>();
        List<Map> comboxData = commonService.createDeptCombox();
        for (Map<String,String> map:comboxData) {
            retData.put(map.get("key"),map.get("value"));
        }
        return retData;
    }
}
